package dao

import "WORKSPACE/models"

func GetAllorders() (error, []models.OrderView, int64) {
	var ordersData []models.OrderView
	var total int64
	err := db.Table("orderview").Find(&ordersData).Error
	return err, ordersData, total
}

func Addorders(order models.Orders) (error) {
	err := db.Table("orders").Create(&order).Error
	return err
}

func Updateorders(order models.Orders) (error) {
	err := db.Table("orders").Where("order_id = ?", order.Order_id).Updates(&order).Error
	return err
}

func Delorders(id string) error {
	err := db.Table("orders").Where("order_id = ?", id).Delete(models.Orders{}).Error
	return err
}